﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using KingSite.SyncDB.Core.Entity;

namespace KingSite.SyncDB.Core.Repository {
    public class DBRepository : BaseProvider {

        public IList<DBEntity> GetAllDBInfo() {
            String stmtId = "DBEntity.FindAll";
            IList<DBEntity> list = SqlMapper.QueryForList<DBEntity>(stmtId, null);
            return list;
        }

        public DBEntity GetDBEntity(int id) {
            String stmtId = "DBEntity.Find";
            DBEntity entity = SqlMapper.QueryForObject<DBEntity>(stmtId, id);
            return entity;
        }

        public void InsertDBEntity(DBEntity entity) {
            if (entity == null) throw new ArgumentNullException("entity");
            String stmtId = "DBEntity.Insert";
            SqlMapper.Insert(stmtId, entity);
        }

        public void UpdateDBEntity(DBEntity entity) {
            if (entity == null) throw new ArgumentNullException("entity");
            String stmtId = "DBEntity.Update";
            SqlMapper.Update(stmtId, entity);
        }

        public void DeleteDBEntity(int id) {
            String stmtId = "DBEntity.Delete";
            SqlMapper.Delete(stmtId, id);
        }

    }
}
